﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NEWS;
public partial class reg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        NEWS.Model.t_user user = new NEWS.Model.t_user();
        user.username = this.username.Text;
        user.password = this.password.Text;
        user.address = this.address.Text;
        user.name = this.name.Text;
        user.sex = int.Parse(this.sex.Text);
        user.mobile = this.mobile.Text;
        user.email = this.email.Text;
        user.qq = this.qq.Text;
        user.state = 1;
        user.adddate = DateTime.Now;
        if (NEWS.BLL.User.Search(this.username.Text) == false)
        {
            NEWS.JsHelper.AlertAndRedirect("用户名已存在！", "reg.aspx");
        }

        if (NEWS.BLL.User.add(user) == true)
        {
            NEWS.JsHelper.AlertAndRedirect("注册成功！", "index.aspx");
        }
        else
        {
            NEWS.JsHelper.AlertAndRedirect("注册失败！", "index.aspx");
        }
    }
}